<template>
	<view class="login-container">
		<view class="head-top-box"></view>
		<!-- 头部 -->
		<view class="header-container">
			<view class="header-box">
				<view class="header-region">
					<view class="left-arrow">
						<view>
							<img src="../../static/fanh.png" alt="">
						</view>
					</view>
					<view class="right-logo">
						<ul>
							<li>
								<h1 class="logo">
									<img src="../../static/logo.jpg" alt="">
								</h1>
								<view href="" class="txt">欢迎登录</view>
							</li>
						</ul>
					</view>
				</view>
			</view>
		</view>
		<view class="content-container">
			<view class="ipt-box">
				<view class="ipt-box-txt">账号：</view>
				<input type="text" class="ipt" placeholder="手机号/邮箱/用户名" v-model="form.username">
			</view>
			<view class="ipt-box">
				<view class="ipt-box-txt">密码：</view>
				<input type="text" class="ipt" placeholder="请输入密码" v-model="form.password">
			</view>
			<view class="login-btn">
				<view @click="goLogin">登录</view>
			</view>
			<view class="register-btn">
				<!-- <view @click="navTo('/pages/login/register')">注册</view> -->
				<view @click="navToRegister()">注册</view>
			</view>
			<view class="forget-txt">
				<view>其他方式登录</view>
				<view class="forget">忘记密码?</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				form: {
					username: '',
					password: ''
				},
			}
		},
		onLoad() {

		},
		methods: {
			navToRegister: function() {
				uni.navigateTo({
					url: '/pages/login/register'
				})
			},
			goLogin: async function() {
				let res = await this.$u.api.goLogin(this.form);
				if (!res.code) {
					this.$u.toast(res.msg);
					return;
				}
				if (res.data.user) {
					this.$u.vuex('vuex_user', res.data.user);
					this.$u.vuex('vuex_token', res.data.user.token);
					// alert("登录成功");
					let that = this
					uni.showModal({
						title: '提示',
						content: '登录成功',
						success: function(res) {
							if (res.confirm) {
								console.log('用户点击确定');
								that.$util.goBack()
							} else if (res.cancel) {
								console.log('用户点击取消');
							}
						}
					});

				}
			}
		}
	}
</script>

<style>
	.head-top-box {
		margin-top: 25px;
	}

	.login-container {
		width: 100%;
		height: 52px;
		background-color: #fff;
		border-bottom: 1px solid #e2e2e2;
	}

	.header-box {
		padding: 5px 5px 0 5px;
		height: 51px;
	}

	.header-regio {
		float: left;
		width: 90%;
	}

	.left-arrow {
		width: 15%;
		float: left;
		height: 39px;
	}

	.left-arrow view {
		display: block;
		width: 100%;
		height: 100%;
	}

	.left-arrow img {
		width: 11px;
		height: 22px;
		margin: 8px 0 0 17px;
	}

	.right-logo {
		float: left;
		width: 65%;
		height: 39px;
		text-align: center;
	}

	.right-logo ul {
		display: inline-block;
	}

	.right-logo li {
		float: left;
		margin: 0 11px;
	}

	.right-logo .logo {
		width: 87px;
		height: 32px;
		float: left;
		margin: 2px 5px 0 0;
	}

	.logo img {
		width: 100%;
		height: 100%;
	}

	.right-logo .txt {
		display: inline-block;
		line-height: 45px;
		font-size: 12px;
		color: #828282;
	}

	.content-container {
		margin: 46.87px 11.7px;
	}

	.ipt-box {
		display: flex;
		margin: 2.9px 0;
		margin-bottom: 35.1px;
		border-bottom: 1px solid #e2e2e2;
	}

	.ipt-box-txt {
		height: 35px;
		line-height: 25px;
		color: #6a6a6a;
		font-size: 14px;
	}

	.ipt-box .ipt {
		width: 293px;
		font-size: 14px;
	}

	.login-btn,
	.register-btn {
		text-align: center;
		margin-top: 17.5px;
	}

	.login-btn view,
	.register-btn view {
		display: block;
		background-color: #e54642;
		height: 48.8px;
		line-height: 48.8px;
		border-radius: 5px;
		font-size: 15.2px;
		color: #fff;
		border: 1px solid #e54642;
	}

	.register-btn view {
		color: #e54642;
		background-color: #fff;
	}

	.forget-txt {
		display: flex;
		justify-content: space-between;
		margin: 17.5px 0;
		overflow: hidden;
	}

	.forget-txt view {
		color: #969696;
		font-size: 14px;
	}
</style>